package com.gigi.controller;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.gigi.model.*;
import com.gigi.service.manual.SignInManageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 签到管理
 */
@RestController
@RequestMapping("sign-in-manage")
public class SignInManageController {

    private final SignInManageService signInManageService;

    public SignInManageController(SignInManageService signInManageService) {
        this.signInManageService = signInManageService;
    }

    @ApiOperation(value = "发布签到")
    @PostMapping("/insert")
    public Response insert(@RequestBody @Valid SignInDO request) {
        return signInManageService.insert(request);
    }

    @ApiOperation(value = "教师签到查询")
    @PostMapping("/get-for-teacher")
    public SingleResponse<SignInDO> getForTeacher(@RequestBody @Valid GetSIgnInRequest request) {
        return signInManageService.getForTeacher(request);
    }

    @ApiOperation(value = "结束签到")
    @PostMapping("/end")
    public Response end(@RequestBody @Valid IdRequest request) {
        return signInManageService.end(request);
    }

    @ApiOperation(value = "学生签到查询")
    @PostMapping("/get-for-student")
    public SingleResponse<SignInDO> getForStudent(@RequestBody @Valid GetSIgnInRequest request) {
        return signInManageService.getForStudent(request);
    }

    @ApiOperation(value = "签到列表")
    @PostMapping("/list")
    public MultiResponse<SignInDO> list(@RequestBody @Valid ListSignInRequest request) {
        return signInManageService.list(request);
    }

    @ApiOperation(value = "补签列表")
    @PostMapping("/extra-list")
    public MultiResponse<SignInDO> extraList(@RequestBody @Valid ListSignInRequest request) {
        return signInManageService.extraList(request);
    }

}